package design.pattern.singleton.lazy;

/**
 * @description: 懒汉式单例 -- 简单
 * @author: liuzhangcheng
 **/
public class LazySimpleSingletonTest {
    public static void main(String[] args) {
        Runnable runnable = ()->{
            // 可以测试下 方法上 synchronized是否添加的打印效果，不添加就有可能会出现多个实例
            LazySimpleSingleton singleton = LazySimpleSingleton.getInstance();
            System.out.println(Thread.currentThread().getName() + ":" + singleton);
        };

        Thread t1 = new Thread(runnable);
        Thread t2 = new Thread(runnable);

        t1.start();
        t2.start();
    }
}
